//app.js
const WebScoketUrl = "wss://api-gz.welink.qq.com/space/websocket/datahub/swmp/messageHub";
// const WebApiUrl = "https://lansheng.njrgrj.com/LanShengDaSha.Weilin/";
const WebApiUrl = "https://lansheng-uat.njrgrj.com/LanShengDaSha.Weilin/";
var fundebug = require("./plug/fundebug.1.3.1.min.js");
fundebug.init({
  apikey: "9cbca6107f5d00f79113969d609b3e6275fe7154c49ee894d5ab10c57815fed0"
});
App({
  onLaunch: function () {
    //头部导航栏设置
    var that = this
    var CapsuleInfo = wx.getMenuButtonBoundingClientRect()
    console.log(JSON.stringify(CapsuleInfo)+'------------------胶囊按钮')
    wx.getSystemInfo({
      success: function (res) {
        that.globalData.platform = res.platform
        // let totalTopHeight = 68
        // if (res.model.indexOf('iPhone X') !== -1) {
        //   totalTopHeight = 88
        // } else if (res.model.indexOf('iPhone') !== -1) {
        //   totalTopHeight = 64
        // }
        that.globalData.statusBarHeight = res.statusBarHeight //状态栏高度
        // that.globalData.titleBarHeight = totalTopHeight - res.statusBarHeight


        var topHeight = CapsuleInfo.top - res.statusBarHeight;
        var heightStat = topHeight + CapsuleInfo.height + 10;
        console.log('自定义高度-----------------' + heightStat + '-------------胶囊高度' + topHeight)
        that.globalData.titleBarHeight = heightStat; //导航栏高度
      },
      failure() {
        that.globalData.statusBarHeight = 0
        that.globalData.titleBarHeight = 0
      }
    })

    //打开调试
    wx.setEnableDebug({
      enableDebug: false
    })
  },

  // onShow: function(){
  //     wx.getUpdateManager().onCheckForUpdate(function (res) {
  //       //请求完新版本信息的回调
  //       console.log("是否有新版本：" + res.hasUpdate);
  //       if (res.hasUpdate) {
  //         wx.getUpdateManager().onUpdateReady(function () {
  //           wx.showModal({
  //             title: '更新提示',
  //             content: '发现新版本，是否重启小程序更新？',
  //             showCancel: false,
  //             success: function (res) {
  //               if (res.confirm) {
  //                 //调用applyUpdate,应用新版本并重启
  //                 wx.getUpdateManager().applyUpdate();
  //               }
  //             }
  //           })
  //         })
  //         wx.getUpdateManager().onUpdateFailed(function () {
  //           wx.showModal({
  //             title: '更新失败',
  //             content: '新版本下载失败，请检查网络',
  //           })
  //         })
  //       }
  //     })
  // },
  globalData: {
    userInfo: null,
    globalphone: '',
    statusBarHeight: 0,
    titleBarHeight: 0,
    WebScoketUrl: WebScoketUrl,
    ProjectGuid: '63d29ef8-199a-5b09-c96c-75ea184167b7',//生产
    //接口地址
    apiInfo: {
      GetAlarmInfoApi: WebApiUrl + 'api/AlarmMessage/GetAlarmInfo', //获取报警信息列表
      GetCountApi: WebApiUrl + 'api/AlarmMessage/GetCount', //根据类型级别状态统计告警信息
      GetStatisticsDataApi: WebApiUrl + 'api/AlarmMessage/getStatisticsData', //根据类型状态起始时间统计告警信息
      changeStatusDataApi: WebApiUrl + 'api/AlarmMessage/changeStatusDataNew', //处理告警记录
      locationDataApi: WebApiUrl + 'api/AlarmMessage/locationData', //获取定位位置
      loginApi: WebApiUrl + 'api/AlarmMessage/login', //登录
      downLoadApi: WebApiUrl + 'api/AlarmMessage/getDownloadVideo', //下载附件
      UploadFileApi: WebApiUrl + "api/AlarmMessage/getUploadFile", //报警详情，上传图片
    }
  }
})